From e3cfa4996cc2603213bf2cb86c979ff1cbacd88a Mon Sep 17 00:00:00 2001 From: robertlipe Date: Sat, 15 Feb 2014 23:18:08 +0000 Subject: [PATCH] Clean up a lot of crumb surrounding NEW_STRINGS. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4745 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/GPSBabel.pro | 2 +- gpsbabel/bcr.cc | 2 +- gpsbabel/csv_util.cc | 75 ++------------------------------------ gpsbabel/delbin.cc | 33 ----------------- gpsbabel/destinator.cc | 12 +----- gpsbabel/duplicate.cc | 5 +++ gpsbabel/garmin_gpi.cc | 13 ------- gpsbabel/gdb.cc | 81 +---------------------------------------- gpsbabel/lowranceusr.cc | 44 +--------------------- gpsbabel/netstumbler.cc | 7 ++-- 10 files changed, 19 insertions(+), 255 deletions(-) diff --git a/gpsbabel/GPSBabel.pro b/gpsbabel/GPSBabel.pro index eafe9c4b1..2756f6cbf 100644 --- a/gpsbabel/GPSBabel.pro +++ b/gpsbabel/GPSBabel.pro @@ -16,7 +16,7 @@ ALL_FMTS=$$MINIMAL_FMTS gtm.cc gpsutil.cc pcx.cc \ saroute.cc navicache.cc psitrex.cc delgpl.cc \ ozi.cc text.cc html.cc netstumbler.cc \ igc.cc brauniger_iq.cc shape.cc hiketech.cc glogbook.cc \ - vcf.cc overlay.cc google.cc xhtmlent.cc lowranceusr.cc an1.cc tomtom.cc \ + vcf.cc google.cc xhtmlent.cc lowranceusr.cc an1.cc tomtom.cc \ tef_xml.cc maggeo.cc vitosmt.cc gdb.cc bcr.cc \ ignrando.cc stmwpp.cc cst.cc nmn4.cc compegps.cc \ yahoo.cc unicsv.cc wfff_xml.cc garmin_txt.cc gpssim.cc \ diff --git a/gpsbabel/bcr.cc b/gpsbabel/bcr.cc index f84e99987..d2de9dada 100644 --- a/gpsbabel/bcr.cc +++ b/gpsbabel/bcr.cc @@ -396,7 +396,7 @@ bcr_route_header(const route_head* route) bcr_write_line(fout, "[CLIENT]", NULL, NULL); /* client section */ bcr_write_line(fout, "REQUEST", NULL, "TRUE"); - sout = CSTRc(route->rte_name); + sout = route->rte_name; if (rtename_opt != 0) { sout = rtename_opt; } diff --git a/gpsbabel/csv_util.cc b/gpsbabel/csv_util.cc index e4b37dbf7..d1531ea0c 100644 --- a/gpsbabel/csv_util.cc +++ b/gpsbabel/csv_util.cc @@ -1605,17 +1605,11 @@ xcsv_waypt_pr(const Waypoint* wpt) } else { write_delimiter = xcsv_file.field_delimiter; } -#if NEW_STRINGS + QString description; QString shortname; if (wpt->shortname.isEmpty() || global_opts.synthesize_shortnames) { if (!wpt->description.isEmpty()) { -#else - char* description = NULL; - char* shortname = NULL; - if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) { - if (wpt->description) { -#endif if (global_opts.synthesize_shortnames) { shortname = mkshort_from_wpt(xcsv_file.mkshort_handle, wpt); } else { @@ -1627,13 +1621,8 @@ xcsv_waypt_pr(const Waypoint* wpt) } else { shortname = csv_stringclean(wpt->shortname, xcsv_file.badchars); } -#if NEW_STRINGS if (wpt->description.isEmpty()) { if (!shortname.isEmpty()) { -#else - if (! wpt->description) { - if (shortname) { -#endif description = csv_stringclean(shortname, xcsv_file.badchars); } else { /* no description -- let description default on output */ @@ -1643,22 +1632,9 @@ xcsv_waypt_pr(const Waypoint* wpt) } if (prefer_shortnames) { -#if NEW_STRINGS -// TODO: try to figure out that original code... description = shortname; } -#else - if (description) { - xfree(description); - } - description = shortname; - } else if (description) { - char* odesc = description; - description = xstrdup(odesc); - xfree(odesc); - } -#endif if ((xcsv_file.gps_datum > -1) && (xcsv_file.gps_datum != GPS_DATUM_WGS84)) { double alt; GPS_Math_WGS84_To_Known_Datum_M(latitude, longitude, 0.0, @@ -1709,16 +1685,11 @@ xcsv_waypt_pr(const Waypoint* wpt) } break; case XT_SHORTNAME: -#if NEW_STRINGS writebuff(buff, fmp->printfc, shortname.isEmpty() ? fmp->val : CSTR(shortname)); -#else - writebuff(buff, fmp->printfc, - (shortname && *shortname) ? shortname : fmp->val); -#endif + break; case XT_ANYNAME: -#if NEW_STRINGS { QString anyname = wpt->shortname; if (anyname.isEmpty()) { @@ -1735,46 +1706,15 @@ xcsv_waypt_pr(const Waypoint* wpt) } writebuff(buff, fmp->printfc, CSTR(anyname)); } -#else - { - char* anyname = NULL; - if (wpt->shortname) { - anyname = xstrdup(wpt->shortname); - } else if (wpt->description) { - anyname = mkshort(xcsv_file.mkshort_handle, wpt->description); - } else if (wpt->notes) { - anyname = xstrdup(wpt->notes); - } else { - anyname = xstrdup(fmp->val); - } - - if ((anyname) && (global_opts.synthesize_shortnames)) { - anyname = xstrdup(shortname); - } - writebuff(buff, fmp->printfc, anyname); - - xfree(anyname); - } -#endif break; case XT_DESCRIPTION: -#if NEW_STRINGS - writebuff(buff, fmp->printfc, + writebuff(buff, fmp->printfc, description.isEmpty() ? fmp->val : CSTR(description)); -#else - writebuff(buff, fmp->printfc, - (description && *description) ? description : fmp->val); -#endif break; case XT_NOTES: -#if NEW_STRINGS writebuff(buff, fmp->printfc, wpt->notes.isEmpty() ? fmp->val : CSTR(wpt->notes)); -#else - writebuff(buff, fmp->printfc, - (wpt->notes && *wpt->notes) ? wpt->notes : fmp->val); -#endif break; case XT_URL: { int off = 0; @@ -2253,16 +2193,7 @@ next: } gbfprintf(xcsv_file.xcsvfp, "%s", xcsv_file.record_delimiter); -#if NEW_STRINGS -#else - if (description && description != shortname) { - xfree(description); - } - if (shortname) { - xfree(shortname); - } -#endif /* increment the index counter */ waypt_out_count++; } diff --git a/gpsbabel/delbin.cc b/gpsbabel/delbin.cc index f4acedaae..243bcf96b 100644 --- a/gpsbabel/delbin.cc +++ b/gpsbabel/delbin.cc @@ -1202,11 +1202,7 @@ get_gc_notes(const Waypoint* wp, int* symbol, char** notes, unsigned* notes_size if (0 == (wp->icon_descr.compare("Geocache Found"))) { gc_sym = 124; } -#if NEW_STRINGS if (!wp->description.isEmpty()) { -#else - if (wp->description) { -#endif gbfputs(wp->description, fd); if (!wp->gc_data->placer.isEmpty()) { gbfprintf(fd, " by %s", wp->gc_data->placer.toUtf8().data()); @@ -1386,11 +1382,7 @@ write_waypoint(const Waypoint* wp) { message_t m; msg_waypoint_t* p; -#if NEW_STRINGS QString name = wp->shortname; -#else - const char* name = wp->shortname; -#endif char* notes; unsigned name_size; unsigned notes_size = 0; @@ -1411,11 +1403,7 @@ write_waypoint(const Waypoint* wp) } else { get_gc_notes(wp, &symbol, ¬es, ¬es_size); notes_freeable = notes; -#if NEW_STRINGS if (!wp->description.isEmpty()) { -#else - if (wp->description) { -#endif name = mkshort(mkshort_handle, wp->description); } } @@ -1812,21 +1800,13 @@ write_track_end(const route_head* track) if (waypoint_n == 0) { return; } -#if NEW_STRINGS if (!track->rte_desc.isEmpty()) { -#else - if (track->rte_desc) { -#endif comment_size = strlen(CSTRc(track->rte_desc)) + 1; } message_init_size(&m, sizeof(msg_track_header_in_t) - 1 + comment_size); p = (msg_track_header_in_t*) m.data; memset(p->name, 0, sizeof(p->name)); -#if NEW_STRINGS if (!track->rte_name.isEmpty()) { -#else - if (track->rte_name) { -#endif strncpy(p->name, CSTRc(track->rte_name), sizeof(p->name) - 1); } else { sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime().toTime_t()); @@ -2161,11 +2141,7 @@ write_route_points(void) shape_n = shape_point_counts[route_point_i]; le_write32(p->total, route_point_n); le_write32(p->index, route_point_i); -#if NEW_STRINGS if (!wp->shortname.isEmpty()) { -#else - if (wp->shortname) { -#endif strncpy(p->name, CSTRc(wp->shortname), sizeof(p->name) - 1); } else { sprintf(p->name, "RPT%u", route_point_i); @@ -2207,12 +2183,7 @@ static void write_route_point(const Waypoint* wp) { wp_array[waypoint_i++] = (Waypoint*)wp; -#if NEW_STRINGS if (wp->shortname.startsWith("SHP")) { -#else - const char* s = wp->shortname; - if (s && s[0] == 'S' && s[1] == 'H' && s[2] == 'P' && s[3] >= '0' && s[3] <= '9') { -#endif shape_point_n++; shape_point_counts[route_point_n]++; } else { @@ -2232,11 +2203,7 @@ write_route_end(const route_head* route) message_init_size(&m, sizeof(msg_route_header_in_t)); p = (msg_route_header_in_t*) m.data; memset(p->name, 0, sizeof(p->name)); -#if NEW_STRINGS if (!route->rte_name.isEmpty()) { -#else - if (route->rte_name) { -#endif strncpy(p->name, CSTRc(route->rte_name), sizeof(p->name) - 1); } else { sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime().toTime_t()); diff --git a/gpsbabel/destinator.cc b/gpsbabel/destinator.cc index cf4291519..29588dcb4 100644 --- a/gpsbabel/destinator.cc +++ b/gpsbabel/destinator.cc @@ -391,13 +391,8 @@ destinator_wpt_disp(const Waypoint* wpt) garmin_fs_t* gmsd = GMSD_FIND(wpt); write_wcstr(DST_DYN_POI); -#if NEW_STRINGS - write_wcstr((!wpt->shortname.isEmpty()) ? CSTRc(wpt->shortname) : "WPT"); + write_wcstr((!wpt->shortname.isEmpty()) ? wpt->shortname : "WPT"); write_wcstr((!wpt->notes.isEmpty()) ? wpt->notes : wpt->description); -#else - write_wcstr((wpt->shortname) ? CSTRc(wpt->shortname) : "WPT"); - write_wcstr((wpt->notes) ? wpt->notes : wpt->description); -#endif write_wcstr(NULL); /* house number */ write_wcstr(GMSD_GET(addr, NULL)); /* street */ @@ -468,13 +463,8 @@ static void destinator_rtept_disp(const Waypoint* wpt) { write_wcstr(DST_ITINERARY); -#if NEW_STRINGS write_wcstr((!wpt->shortname.isEmpty()) ? wpt->shortname : "RTEPT"); write_wcstr((!wpt->notes.isEmpty()) ? wpt->notes : wpt->description); -#else - write_wcstr((wpt->shortname) ? CSTRc(wpt->shortname) : "RTEPT"); - write_wcstr((wpt->notes) ? wpt->notes : wpt->description); -#endif gbfputint32(0, fout); gbfputdbl(0, fout); diff --git a/gpsbabel/duplicate.cc b/gpsbabel/duplicate.cc index b04c3f85d..2697f6822 100644 --- a/gpsbabel/duplicate.cc +++ b/gpsbabel/duplicate.cc @@ -193,8 +193,13 @@ duplicate_process(void) bh = htable; i = 0; +#if NEWQ + foreach(Waypoint* waypointp, waypt_list) { + bh->wpt = waypointp; +#else QUEUE_FOR_EACH(&waypt_head, elem, tmp) { bh->wpt = (Waypoint*) elem; +#endif bh->index = i; i ++; bh ++; diff --git a/gpsbabel/garmin_gpi.cc b/gpsbabel/garmin_gpi.cc index 99db4bef4..62c0e400e 100644 --- a/gpsbabel/garmin_gpi.cc +++ b/gpsbabel/garmin_gpi.cc @@ -544,27 +544,14 @@ read_tag(const char* caller, const int tag, Waypoint* wpt) /* speed isn't part of a normal waypoint WAYPT_SET(wpt, speed, speed); */ -#if NEW_STRINGS if ((wpt->shortname.isEmpty() || (wpt->shortname).indexOf('@'))) { -#else - if ((wpt->shortname == NULL) || (! strchr(wpt->shortname, '@'))) { -#endif if (units == 's') { speed = MPS_TO_MPH(speed); } else { speed = MPS_TO_KPH(speed); } -#if NEW_STRINGS -// double check QString base = wpt->shortname.isEmpty() ? "WPT" : wpt->shortname; wpt->shortname = base + QString("@.%1").arg(speed); -#else - xasprintf(&str, "%s@%.f", wpt->shortname ? CSTRc(wpt->shortname) : "WPT", speed); - if (wpt->shortname) { - xfree(wpt->shortname); - } - wpt->shortname = str; -#endif } } diff --git a/gpsbabel/gdb.cc b/gpsbabel/gdb.cc index 08582b12d..db5f3d12f 100644 --- a/gpsbabel/gdb.cc +++ b/gpsbabel/gdb.cc @@ -334,20 +334,11 @@ static Waypoint* gdb_find_wayptq(const queue* Q, const Waypoint* wpt, const char exact) { queue* elem, *tmp; -#if NEW_STRINGS QString name = wpt->shortname; -#else - const char* name = wpt->shortname; -#endif QUEUE_FOR_EACH(Q, elem, tmp) { Waypoint* tmp = (Waypoint*)elem; -#if NEW_STRINGS if (name.compare(tmp->shortname,Qt::CaseInsensitive) == 0) { -#else - if (case_ignore_strcmp(name, tmp->shortname) == 0) { -#endif - if (! exact) { return tmp; } @@ -405,11 +396,7 @@ gdb_add_route_waypt(route_head* rte, Waypoint* ref, const int wpt_class) } } res = NULL; -#if NEW_STRINGS turn_point = (gdb_roadbook && (wpt_class > gt_waypt_class_map_point) && !tmp->description.isEmpty()); -#else - turn_point = (gdb_roadbook && (wpt_class > gt_waypt_class_map_point) && tmp->description); -#endif if (turn_point || (gdb_via == 0) || (wpt_class < gt_waypt_class_map_point)) { res = new Waypoint(*tmp); route_add_wpt(rte, res); @@ -421,7 +408,6 @@ gdb_add_route_waypt(route_head* rte, Waypoint* ref, const int wpt_class) /*******************************************************************************/ /* TOOLS AND MACROS FOR THE WRITER */ /*-----------------------------------------------------------------------------*/ -#if NEW_STRINGS void FWRITE_CSTR(QString a) { if (a.isEmpty()) { gbfputc(0, fout); @@ -433,9 +419,7 @@ void FWRITE_CSTR(QString a) { gbfputcstr(a.toLatin1().constData(), fout); } } -#else -#define FWRITE_CSTR(a) ((a) == NULL) ? gbfputc(0,fout) : gbfputcstr((a),fout) -#endif + #define FWRITE_i16(a) gbfputint16((a),fout) #define FWRITE_i32(a) gbfputint32((a),fout) #define FWRITE(a, b) gbfwrite(a,(b),1,fout) @@ -772,11 +756,7 @@ read_waypoint(gt_waypt_classes_e* waypt_class_out) GMSD_SETSTR(country, gt_get_icao_country(str)); } } -#if NEW_STRINGS if (gdb_roadbook && (wpt_class > gt_waypt_class_map_point) && !res->description.isEmpty()) { -#else - if (gdb_roadbook && (wpt_class > gt_waypt_class_map_point) && res->description) { -#endif wpt_class = gt_waypt_class_user_waypoint; GMSD_SET(wpt_class, wpt_class); #ifdef GMSD_EXPERIMENTAL @@ -1338,30 +1318,18 @@ gdb_check_waypt(Waypoint* wpt) } if ((wpt->latitude < -90) || (wpt->latitude > 90.0)) -#if NEW_STRINGS fatal("Invalid latitude %f in waypoint %s.\n", lat_orig, !wpt->shortname.isEmpty() ? CSTRc(wpt->shortname) : ""); if ((wpt->longitude < -180) || (wpt->longitude > 180.0)) fatal("Invalid longitude %f in waypoint %s.\n", lon_orig, !wpt->shortname.isEmpty() ? CSTRc(wpt->shortname) : ""); -#else - fatal("Invalid latitude %f in waypoint %s.\n", - lat_orig, wpt->shortname ? CSTRc(wpt->shortname) : ""); - if ((wpt->longitude < -180) || (wpt->longitude > 180.0)) - fatal("Invalid longitude %f in waypoint %s.\n", - lon_orig, wpt->shortname ? CSTRc(wpt->shortname) : ""); -#endif } /*-----------------------------------------------------------------------------*/ static void write_waypoint( -#if NEW_STRINGS const Waypoint* wpt, const QString& shortname, garmin_fs_t* gmsd, -#else - const Waypoint* wpt, const char* shortname, garmin_fs_t* gmsd, -#endif const int icon, const int display) { char zbuf[32], ffbuf[32]; @@ -1397,11 +1365,7 @@ write_waypoint( FWRITE_LATLON(wpt->latitude); /* latitude */ FWRITE_LATLON(wpt->longitude); /* longitude */ FWRITE_DBL(wpt->altitude, unknown_alt); /* altitude */ -#if NEW_STRINGS if (!wpt->notes.isEmpty()) { -#else - if (wpt->notes) { -#endif FWRITE_CSTR(wpt->notes); } else { FWRITE_CSTR(wpt->description); @@ -1698,27 +1662,6 @@ finalize_item(gbfile* origin, const char identifier) } /*-----------------------------------------------------------------------------*/ -#if NEW_STRINGS -#else -static char -str_not_equal(const char* s1, const char* s2) -{ - if (s1) { - if (!s2) { - return 1; - } - if (strcmp(s1, s2) != 0) { - return 1; - } else { - return 0; - } - } else if (s2) { - return 1; - } else { - return 0; - } -} -#endif static void write_waypoint_cb(const Waypoint* refpt) @@ -1745,22 +1688,13 @@ write_waypoint_cb(const Waypoint* refpt) } if ((test != NULL) && (route_flag == 0)) { -#if NEW_STRINGS if (test->notes != refpt->notes) { -#else - if (str_not_equal(test->notes, refpt->notes)) { -#endif test = NULL; } } if (test == NULL) { int icon, display, wpt_class; -#if NEW_STRINGS - QString name; -#else - char* name; -#endif Waypoint* wpt = new Waypoint(*refpt); gdb_check_waypt(wpt); @@ -1806,9 +1740,8 @@ write_waypoint_cb(const Waypoint* refpt) break; } - name = wpt->shortname; + QString name = wpt->shortname; -#if NEW_STRINGS if (global_opts.synthesize_shortnames || name.isEmpty()) { name = wpt->notes; if (name.isEmpty()) { @@ -1817,16 +1750,6 @@ write_waypoint_cb(const Waypoint* refpt) if (name.isEmpty()) { name = wpt->shortname; } -#else - if (global_opts.synthesize_shortnames || (*name == '\0')) { - name = wpt->notes; - if (!name) { - name = wpt->description; - } - if (!name) { - name = wpt->shortname; - } -#endif } name = mkshort(short_h, name); diff --git a/gpsbabel/lowranceusr.cc b/gpsbabel/lowranceusr.cc index 16391c185..b2fc75678 100644 --- a/gpsbabel/lowranceusr.cc +++ b/gpsbabel/lowranceusr.cc @@ -704,7 +704,6 @@ lowranceusr_waypt_disp(const Waypoint* wpt) } /* Try and make sure we have a name */ -#if NEW_STRINGS // this kind of thing would probably be more readable like // name = blah. // if name.isEmpty() @@ -720,26 +719,12 @@ lowranceusr_waypt_disp(const Waypoint* wpt) name = wpt->shortname; } else if (!wpt->description.isEmpty()) { name = wpt->description; -#else - char* name = NULL; - if ((! wpt->shortname) || global_opts.synthesize_shortnames) { - if (wpt->description && global_opts.synthesize_shortnames) { - name = mkshort_from_wpt(mkshort_handle, wpt); - } else if (wpt->shortname) { - name = wpt->shortname; - } else if (wpt->description) { - name = wpt->description; -#endif } } else { name = wpt->shortname; } -#if NEW_STRINGS text_len = name.length(); -#else - text_len = strlen(name); -#endif if (text_len > MAXUSRSTRINGSIZE) { text_len = MAXUSRSTRINGSIZE; } @@ -753,11 +738,7 @@ lowranceusr_waypt_disp(const Waypoint* wpt) /** * Comments are now used by the iFinder (Expedition C supports them) */ -#if NEW_STRINGS if (wpt->description != wpt->shortname) { -#else - if (wpt->description && strcmp(wpt->description, wpt->shortname) != 0) { -#endif comment = xstrdup(wpt->description); text_len = strlen(comment); if (text_len > MAXUSRSTRINGSIZE) { @@ -866,18 +847,11 @@ lowranceusr_track_hdr(const route_head* trk) char visible=1; ++trail_count; -#if NEW_STRINGS -// This whole function needs to be replaced... +//TODO: This whole function needs to be replaced... if (!trk->rte_name.isEmpty()) { name = xstrdup(trk->rte_name); } else if (!trk->rte_desc.isEmpty()) { name = xstrdup(trk->rte_desc); -#else - if (trk->rte_name) { - name = xstrdup(trk->rte_name); - } else if (trk->rte_desc) { - name = xstrdup(trk->rte_desc); -#endif } else { tmp_name[0]='\0'; snprintf(tmp_name, sizeof(tmp_name), "Babel %d", trail_count); @@ -927,18 +901,11 @@ lowranceusr_route_hdr(const route_head* rte) char route_reversed=0; /* route name */ -#if NEW_STRINGS -// This whole function needs to be replaced... + //TODO: This whole function needs to be replaced... if (!rte->rte_name.isEmpty()) { name = xstrdup(rte->rte_name); } else if (!rte->rte_desc.isEmpty()) { name = xstrdup(rte->rte_desc); -#else - if (rte->rte_name) { - name = xstrdup(rte->rte_name); - } else if (rte->rte_desc) { - name = xstrdup(rte->rte_desc); -#endif } else { tmp_name[0]='\0'; snprintf(tmp_name, sizeof(tmp_name), "Babel R%d", ++lowrance_route_count); @@ -992,17 +959,10 @@ lowranceusr_merge_track_hdr(const route_head* trk) char* name, tmp_name[20]; if (++trail_count == 1) { -#if NEW_STRINGS if (!trk->rte_name.isEmpty()) { name = xstrdup(trk->rte_name); } else if (!trk->rte_desc.isEmpty()) { name = xstrdup(trk->rte_desc); -#else - if (trk->rte_name) { - name = xstrdup(trk->rte_name); - } else if (trk->rte_desc) { - name = xstrdup(trk->rte_desc); -#endif } else { tmp_name[0]='\0'; snprintf(tmp_name, sizeof(tmp_name), "Babel %d", trail_count); diff --git a/gpsbabel/netstumbler.cc b/gpsbabel/netstumbler.cc index 330667cc8..f80e0d30c 100644 --- a/gpsbabel/netstumbler.cc +++ b/gpsbabel/netstumbler.cc @@ -304,9 +304,10 @@ fix_netstumbler_dupes(void) #if NEWQ // Why, oh, why is this format running over the entire waypoint list and // modifying it? This seems wrong. - extern QList waypt_list; - foreach(Waypoint* waypointp, waypt_list) { - bh->wpt = waypointp; +// extern QList waypt_list; +// foreach(Waypoint* waypointp, waypt_list) { +// bh->wpt = waypointp; + if (false) { #else queue* elem, *tmp; extern queue waypt_head; -- 2.30.2